package cn.hl.hm.controller.st;

import cn.hl.hm.controller.driver.DriverInfoController;
import cn.hl.hm.logic.manage.VehicleManageLogic;
import cn.hl.hm.logic.st.StOrderLogic;
import cn.hl.hm.util.InfoCode;
import cn.hl.hm.vo.StOrderVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * 零担订单同步到干线
 * Created by xianghan on 17/12/12.
 */
@Controller
@RequestMapping(value = "/st/")
public class StOrderController {
    private static final Logger logger = LoggerFactory.getLogger(StOrderController.class);
    @Autowired
    private StOrderLogic stOrderLogic;

    @RequestMapping(value = "/order/sync", method = RequestMethod.POST)
    public String vehicleList(@RequestBody StOrderVo stOrder,
                              HttpServletRequest request, ModelMap modelMap) throws IOException {
        logger.info("订单---同步---/st/order/sync");
        try {
            if (stOrderLogic.syncStOrderToHm(stOrder)) {
                modelMap.addAttribute("infoCode", InfoCode.SUCCESS);
            } else {
                modelMap.addAttribute("infoCode", InfoCode.FAILURE);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "result";
    }



}
